/*
 * @Author: ljkt
 * @Version: 2.0
 * @Date: 2022-05-16 11:06:33
 * @LastEditors: ljkt
 * @LastEditTime: 2025-02-20 12:27:43
 * @Description:
 */
#include "Hal_Common_Func.h"
unsigned char Hal_Gpio_Get(s_gpio_in_t *config)
{
	unsigned char ret = 0;
	switch (config->portx)
	{
#ifdef EN_PORT0
	case HAL_PORT0:
		ret = GET_BIT(DATAA, config->pinx);
		break;
#endif
#ifdef EN_PORT1
	case HAL_PORT1:
		ret = GET_BIT(DATAB, config->pinx);
		break;
#endif
#ifdef EN_PORT2
	case HAL_PORT2:
		ret = GET_BIT(DATAC, config->pinx);
		break;
#endif
#ifdef EN_PORT3
	case HAL_PORT3:
		ret = GET_BIT(DATAD, config->pinx);
		break;
#endif
#ifdef EN_PORT4
	case HAL_PORT4:
		break;
#endif
#ifdef EN_PORT5
	case HAL_PORT5:
		break;
#endif
	default:
		break;
	}
	return ret;
}
void Hal_Gpio_In(s_gpio_in_t *config)
{
	switch (config->portx)
	{
#ifdef EN_PORT0
	case HAL_PORT0:
		SET_BIT(PU_PA, config->pinx);
		SET_BIT(TRISA, config->pinx);
		break;
#endif
#ifdef EN_PORT1
	case HAL_PORT1:
		SET_BIT(PU_PB, config->pinx);
		SET_BIT(TRISB, config->pinx);
		break;
#endif
#ifdef EN_PORT2
	case HAL_PORT2:
		SET_BIT(PU_PC, config->pinx);
		SET_BIT(TRISC, config->pinx);
		break;
#endif
#ifdef EN_PORT3
	case HAL_PORT3:
		SET_BIT(PU_PD, config->pinx);
		SET_BIT(TRISD, config->pinx);
		break;
#endif
#ifdef EN_PORT4
	case HAL_PORT4:
		break;
#endif
#ifdef EN_PORT5
	case HAL_PORT5:
		break;
#endif
	default:
		break;
	}
}
void Hal_Gpio_Set(s_gpio_out_t *config, unsigned char level)
{
	switch (config->portx)
	{
#ifdef EN_PORT0
	case HAL_PORT0:
		(level ? (SET_BIT(DATAA, config->pinx)) : (CLR_BIT(DATAA, config->pinx)));
		break;
#endif
#ifdef EN_PORT1
	case HAL_PORT1:
		(level ? (SET_BIT(DATAB, config->pinx)) : (CLR_BIT(DATAB, config->pinx)));
		break;
#endif
#ifdef EN_PORT2
	case HAL_PORT2:
		(level ? (SET_BIT(DATAC, config->pinx)) : (CLR_BIT(DATAC, config->pinx)));
		break;
#endif
#ifdef EN_PORT3
	case HAL_PORT3:
		(level ? (SET_BIT(DATAD, config->pinx)) : (CLR_BIT(DATAD, config->pinx)));
		break;
#endif
#ifdef EN_PORT4
	case HAL_PORT4:
		break;
#endif
#ifdef EN_PORT5
	case HAL_PORT5:
		break;
#endif
	default:
		break;
	}
}
void Hal_Gpio_Set_Isr(s_gpio_out_t *config, unsigned char level)
{
	switch (config->portx)
	{
#ifdef EN_PORT0
	case HAL_PORT0:
		(level ? (SET_BIT(DATAA, config->pinx)) : (CLR_BIT(DATAA, config->pinx)));
		break;
#endif
#ifdef EN_PORT1
	case HAL_PORT1:
		(level ? (SET_BIT(DATAB, config->pinx)) : (CLR_BIT(DATAB, config->pinx)));
		break;
#endif
#ifdef EN_PORT2
	case HAL_PORT2:
		(level ? (SET_BIT(DATAC, config->pinx)) : (CLR_BIT(DATAC, config->pinx)));
		break;
#endif
#ifdef EN_PORT3
	case HAL_PORT3:
		(level ? (SET_BIT(DATAD, config->pinx)) : (CLR_BIT(DATAD, config->pinx)));
		break;
#endif
#ifdef EN_PORT4
	case HAL_PORT4:
		break;
#endif
#ifdef EN_PORT5
	case HAL_PORT5:
		break;
#endif
	default:
		break;
	}
}
void Hal_Gpio_Out(s_gpio_out_t *config, unsigned char level)
{
	Hal_Gpio_Set(config, level);
	switch (config->portx)
	{
#ifdef EN_PORT0
	case HAL_PORT0:
		CLR_BIT(TRISA, config->pinx);
		break;
#endif
#ifdef EN_PORT1
	case HAL_PORT1:
		CLR_BIT(TRISB, config->pinx);
		break;
#endif
#ifdef EN_PORT2
	case HAL_PORT2:
		CLR_BIT(TRISC, config->pinx);
		break;
#endif
#ifdef EN_PORT3
	case HAL_PORT3:
		CLR_BIT(TRISD, config->pinx);
		break;
#endif
#ifdef EN_PORT4
	case HAL_PORT4:
		break;
#endif
#ifdef EN_PORT5
	case HAL_PORT5:
		break;
#endif
	default:
		break;
	}
}
